#!/bin/bash
#功能函数
funcs=./functions.sh
if test ! -f $funcs; then
    funcs=`which functions.sh`
    if [ "$funcs" = "" ]; then
        echo "functions.sh not exist!!"
        return
    else
        echo "funcs=$funcs"
	. $funcs
    fi
else
    echo "funcs=$funcs"
    . $funcs  
fi

function setup_xdmcp_7.04()
{
    sudo sed -i "s/#RemoteGreeter=\/usr\/lib\/gdm\/gdmlogin/RemoteGreeter=\/usr\/lib\/gdm\/gdmlogin/g"  $1
    sudo sed -i "s/Enable=false/Enable=true/g"                     $1
}

#ubuntu 910/karmic 启用xdmcp的方法 http://blog.wsdd.org/?p=595
function setup_xdmcp_9.10()
{
     echoTextBlue "run shell func setup_xdmcp_9.10 ......"
     gdm_custom_conf=/usr/share/doc/gdm/examples/custom.conf
     if test -f $gdm_custom_conf; then 
         cp $gdm_custom_conf /tmp/custom.conf -rf
     else
         echoTextRed "file $gdm_custom_conf not exist!!"
         return
     fi
     ac_lineno=`sed -n '/\[security\]/='    /tmp/custom.conf`
     sed -i "/\[security\]/a\Enable=true" /tmp/custom.conf
     echo "ac_lineno=$ac_lineno"
     sudo cp /tmp/custom.conf /etc/gdm/custom.conf
}

function setup_xdmcp_10.04()
{
    setup_xdmcp_9.10
}

function setup_xdmcp_10.04.1()
{
    setup_xdmcp_9.10   
}

function setup_xdmcp_10.10()
{
    echoTextBlue "run shell func setup_xdmcp_10.10 ......"
    local gdm_deb_url="https://launchpad.net/~tellis/+archive/customer1/+build/2093798/+files/gdm_2.30.5-0ubuntu5%7Eppa2_i386.deb"
    #wget   $gdm_deb_url --directory-prefix=/tmp/ --no-clobber
    if test -f /tmp/gdm_*.deb; then
        sudo dpkg -i /tmp/gdm_*.deb
    else
        echo "/tmp/gdm_*.deb not exist!!"
    fi
}

#脚本入口
if [ -n "$1" ]; then
    setup_xdmcp_$1
else
    setup_xdmcp_`sh_get_ubuntu_version`
fi
exit


################################################################################
参考资料：
ubuntu 910/karmic 启用xdmcp的方法
http://blog.wsdd.org/?p=595
Ubuntu下安装xdmcp服务 使用Xmanager接入
http://www.linuxidc.com/Linux/2009-03/18816.htm
Xmanager 2.0 使用详解
http://blog.chinaunix.net/u1/49742/showart.php?id=405657
http://blog.wsdd.org/?p=595


sudo apt-get install libxpm-dev
修改 /etc/gdm/gdm.conf 文件
MaxSessions=16
sudo apt-get install xfonts-cyrillic
sudo apt-get install xnest
linux下xdmp登录客户端
tsclient
每次连接的时候要启动服务器端的gdm 
sudo restart gdm
注意事项：
